Vulkan: wrap external buffers as regions#9110
Open
xFile3160 wants to merge 2 commits intohalide:mainfrom
Open
Conversation
Member
|
This description sounds written by AI. Per our contribution guidelines, please disclose any AI tool usage or assert that none was used. |
Author
|
Indeed. I did not review yet. Please don't until I do and I update description. Those things work on their own now |
Member
|
@xFile3160 -- when ready for review, change the status away from Draft. |
halide_vulkan_wrap_vk_buffer stored the raw VkBuffer in halide_buffer_t::device, but the Vulkan runtime expects that field to point at MemoryRegion metadata. Wrap external VkBuffer handles in small runtime-owned MemoryRegion metadata instead. Detach/free release only that metadata, not the external buffer. Add an explicit-offset wrap helper for views into larger buffers, and include that offset in descriptor updates and copy paths. Refs halide#8715
1398255 to
d7ca1b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the Vulkan native-buffer wrapper path.
The issue in #8715 started from trying to pass an application-owned
VkBufferto Halide. The only way to make that work reliably was to mirror Halide's
private
MemoryRegionlayout in application code and pass that throughhalide_vulkan_wrap_vk_buffer. That is not a good API boundary.halide_vulkan_wrap_vk_buffershould accept a Vulkan buffer handle and letHalide build whatever runtime metadata it needs internally.
This PR changes the wrapper path to do that. External
VkBufferhandles arewrapped in small runtime-owned
MemoryRegionmetadata. The Vulkan bufferremains owned by the caller; Halide only owns the metadata needed to pass the
buffer through descriptor updates, copies, crops, and detach/free.
The intended flow is:
VkBuffer.halide_buffer_t.VkBuffer.This also adds
halide_vulkan_wrap_vk_buffer_with_offsetfor views into largerVulkan buffers. The explicit external offset is included in descriptor updates
and copy paths. Regular Halide crops continue to use the existing indexing
offset path.
The GPU object lifetime test now covers Vulkan native buffer wrapping. It
rewraps a Vulkan buffer handle, then wraps the same buffer with an explicit byte
offset and verifies that the shifted view copies back the expected values.
Refs #8715